package com.itheima.mapper;


import com.itheima.pojo.Clazz;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
    //---------------------------原始方法，考虑分页---------------------------------
//    @Select("SELECT count(*) from emp e left join dept d on e.dept_id=d.id")
//    public Long count();
//    @Select("SELECT e.*,d.name deptName from emp e left join dept d on d.id=e.dept_id order by e.update_time desc limit #{start},#{pageSize}")
//    public List<Emp> list(Integer start,Integer pageSize);

    //---------------------------pagehelper-------------------------------------
    //@Select("SELECT e.*,d.name deptName from emp e left join dept d on d.id=e.dept_id where e.name like '%#{name}%' order by e.update_time desc")
    public List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);


    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time)" +
            " values(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);



    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);


    void updateById(Emp emp);
    /*
    * 统计员工职位信息
    * */
    @MapKey("pos")
    List<Map<String,Object>> countEmpJobData();

    @MapKey("name")
    List<Map<String,Object>> countEmpGenderData();


    Emp selectByUsernameAndPassword(Emp emp);
}
